package com.zhang.controller;

import com.zhang.vo.UserVO;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.Date;

@Controller
public class IndexController {

    @RequestMapping("/index")
    public ModelAndView index(ModelAndView modelAndView){
        modelAndView.addObject("title","传递的title");
        modelAndView.addObject("data","传递的数据");
        modelAndView.setViewName("index");
        return modelAndView;
    }

    @RequestMapping("/basic")
    public String index(Model model){
        UserVO userVO = new UserVO();
        userVO.setUsername("Lee");
        userVO.setAge(22);
        userVO.setIsVip(true);
        userVO.setCreatTime(new Date());
        userVO.setSex(1);
        userVO.setTags(Arrays.asList("php","java","c++"));

        model.addAttribute("user",userVO);
        return  "basic";
    }

}




